package com.yuan.member.controller;

import cn.common.enums.SmsEnum;
import cn.common.result.Response;

import com.yuan.member.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/sms")
public class SmsController {
    @Autowired
    private SmsService smsService;
    /**
     * 发送验证码
     */
    @PostMapping("/sendMail")
    public void sendMail(@RequestParam String mailbox, @RequestParam SmsEnum type) {
        smsService.sendMail(mailbox, type);
    }

    /**
     * @param phone
     * @param phoneCode
     * @param type
     */
    @PostMapping("/sendSms")
    public Response sendSms(@RequestParam String phone,
                            String phoneCode,
                            SmsEnum type) {
        smsService.sendSms(phone, phoneCode, type);
        return Response.Success();
    }
}
